
class.save_ui = extends(class.panel){

    reload = true,
    fdf = 'tooltip_backdrop0',
    name = '游戏存档',
    show_flag = false,
    init = function (self)

        class.panel.init(self)
        --目录区域
        self.map = self:add_panel('',10,10,130,self.h-20)
        self.map:add_panel([[ReplaceableTextures\TeamColor\TeamColor09.blp]],self.map.w + 10,0,2,self.map.h)
        --显示区域
        self.show_panel = self.map:add_panel('',self.map.w + 10,0,self.w - self.map.w - 40)
        
        --esc
        local button = self:add_button([[ui\关闭1.tga]],self.w-64,0,64,64)
        button.highlight = button:add_panel([[ui\关闭2.tga]])
        button.highlight:hide()
        self.esc = button
        
        return self
    end,

    new = function (parent,name,x,y,w,h,icon_param)
        local panel = class.save_ui:builder 
        {
            parent = parent,
            name = name,
            x = x,
            y = y,
            w = w,
            h = h,
            icon_param = icon_param,
        }
        return panel
    end,
    map_index = 0,
    add_map = function(self,name,class_name)
        local h = 50
        local button = self.map:add_namebutton(name,0,self.map_index*(h + 1),nil,h,14)
        local panel = self.show_panel:add(class_name)
        button.class = '菜单按钮'
        panel:hide()
        button.panel = panel
        self.map_index = self.map_index + 1
        if self.map_index==1 then
            self:on_button_clicked(button)
        end
    end,
    update = function(self,data)
        if self.select_map then
            local panel = self.select_map.panel
            panel:update()
        end
    end,
    on_button_clicked = function(self,button)
        if button==self.esc then
            self:hide()
        elseif button.class=='菜单按钮' then
            if self.select_map then
                self.select_map.text:set_color(0xffffffff)
                self.select_map.panel:hide()
            end
            self.select_map = button
            self.select_map.text:set_color(0xff00ff00)
            self.select_map.panel:show()
            self.select_map.panel:update(true)
            
        end
    end,
}


--local maps = {'特殊福利','等级存档','通关存档','装扮存档','商城道具'}
local w,h = 1000,600
local ui = class.save_ui.create('存档',(1920 - w)/2,100,w,h)
--ui:show()
ac.wait(100,function()
    ui:add_map('存档装备',class.save_ui1)
    ui:add_map('通关存档',class.save_ui3)
    ui:add_map('天赋树',class.save_ui2)
end)


ac.game:event '玩家-刷新UI'(function(_,player)
    if player:is_self() and ui:is_show() then
        ui:update()
    end
end)


local button = class.button.create('',120,50,80,80,1)
button:add_frame('tooltip_backdrop0')
button.text = button:add_text('存档|nF4',0,0,nil,nil,16,5)
button:set_highlight([[UI\Widgets\BattleNet\bnet-button01-highlight-mouse.blp]])
button.hotkey = 'F4'
function button:on_button_key_down()
    self:on_button_clicked()
end

function button:on_button_clicked()
    if ui:is_show() then
        ui:hide()
    else
        ui:show()
    end
end

ac.game:notify('游戏-注册显示UI',ui,true)